<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Non-instantiable non-classed fundamental types: GObject Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GObject Reference Manual">
<link rel="up" href="chapter-gtype.html" title="The GLib Dynamic Type System">
<link rel="prev" href="gtype-conventions.html" title="Conventions">
<link rel="next" href="gtype-instantiable-classed.html" title="Instantiable classed types: objects">
<meta name="generator" content="GTK-Doc V1.26.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="chapter-gtype.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="gtype-conventions.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="gtype-instantiable-classed.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="gtype-non-instantiable"></a>Non-instantiable non-classed fundamental types</h2></div></div></div>
<p>
          A lot of types are not instantiable by the type system and do not have
          a class. Most of these types are fundamental trivial types such as <span class="emphasis"><em>gchar</em></span>, 
          and are already registered by GLib.
        </p>
<p>
          In the rare case of needing to register such a type in the type
          system, fill a
          <a class="link" href="gobject-Type-Information.html#GTypeInfo" title="struct GTypeInfo"><span class="type">GTypeInfo</span></a> structure with zeros since these types are also most of the time
          fundamental:
          </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24</pre></td>
        <td class="listing_code"><pre class="programlisting">GTypeInfo info <span class="gtkdoc opt">= {</span>
  <span class="number">0</span><span class="gtkdoc opt">,</span>                                <span class="comment">/* class_size */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* base_init */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* base_destroy */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* class_init */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* class_destroy */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* class_data */</span>
  <span class="number">0</span><span class="gtkdoc opt">,</span>                                <span class="comment">/* instance_size */</span>
  <span class="number">0</span><span class="gtkdoc opt">,</span>                                <span class="comment">/* n_preallocs */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* instance_init */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* value_table */</span>
<span class="gtkdoc opt">};</span>
<span class="gtkdoc kwb">static const</span> GTypeValueTable value_table <span class="gtkdoc opt">= {</span>
  value_init_long0<span class="gtkdoc opt">,</span>                <span class="comment">/* value_init */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* value_free */</span>
  value_copy_long0<span class="gtkdoc opt">,</span>                <span class="comment">/* value_copy */</span>
  NULL<span class="gtkdoc opt">,</span>                        <span class="comment">/* value_peek_pointer */</span>
  <span class="string">&quot;i&quot;</span><span class="gtkdoc opt">,</span>                        <span class="comment">/* collect_format */</span>
  value_collect_int<span class="gtkdoc opt">,</span>        <span class="comment">/* collect_value */</span>
  <span class="string">&quot;p&quot;</span><span class="gtkdoc opt">,</span>                        <span class="comment">/* lcopy_format */</span>
  value_lcopy_char<span class="gtkdoc opt">,</span>                <span class="comment">/* lcopy_value */</span>
<span class="gtkdoc opt">};</span>
info<span class="gtkdoc opt">.</span>value_table <span class="gtkdoc opt">= &amp;</span>value_table<span class="gtkdoc opt">;</span>
type <span class="gtkdoc opt">=</span> <span class="function"><a href="gobject-Type-Information.html#g-type-register-fundamental">g_type_register_fundamental</a></span> <span class="gtkdoc opt">(</span>G_TYPE_CHAR<span class="gtkdoc opt">,</span> <span class="string">&quot;gchar&quot;</span><span class="gtkdoc opt">, &amp;</span>info<span class="gtkdoc opt">, &amp;</span>finfo<span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
        </p>
<p>
          Having non-instantiable types might seem a bit useless: what good is a type
          if you cannot instantiate an instance of that type ? Most of these types
          are used in conjunction with <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>s: a GValue is initialized
          with an integer or a string and it is passed around by using the registered 
          type's value_table. <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>s (and by extension these trivial fundamental
          types) are most useful when used in conjunction with object properties and signals.
        </p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.26.1</div>
</body>
</html>